import {mailboxList} from "@/api/chat";
import {getIssues} from "@/api/auth";

export default {
    setMailNum ({ commit, state }) {
        mailboxList().then((response) => {
            let data = response.data.mailbox_list
            let total = 0
            let unseenNum = []
            for (let i = 0; i < data.length; i++) {
                total += data[i].unseen_num__sum
                data[i].unseen_num__sum ? unseenNum.push(data[i].unseen_num__sum) : unseenNum.push(0)
            }
            unseenNum.unshift(total)
            let overview = state.overview
            overview.new_mail_num = unseenNum
            commit('SET_OVERVIEW', overview)
        })
    },
    setIssueNum({ commit }) {
        getIssues().then(res => {
            commit('SET_ISSUES_NUM', res.data.data)
        })
    }
}
